<template>
  <!-- 如果goods是空的话就不渲染了 -->
  <div v-if="Object.keys(goods).length !== 0" class="base-info">
    <div class="info-title">{{ goods.title }}</div>
    <div class="info-price">
      <span class="n-price">{{ goods.newPrice }}</span>
      <span class="o-price">{{ goods.oldPrice }}</span>
      <span v-if="goods.discount" class="discount">{{ goods.discount }}</span>
    </div>
    <div class="info-other">
      <span>{{ goods.columns[0] }}</span>
      <span>{{ goods.columns[1] }}</span>
      <span>{{ goods.services[goods.services.length - 1].name }}</span>
    </div>
    <div class="info-service">
      <!-- 这里遍历数字 从 1 到 length-1 -->
      <span
        class="info-service-item"
        v-for="index in goods.services.length - 1"
        :key="index"
      >
        <img :src="goods.services[index - 1].icon" alt="" />
        <span>{{ goods.services[index - 1].name }}</span>
      </span>
    </div>
  </div>
</template>

<script>
export default {
  name: "DetailBaseInfo",
  props: {
    goods: {
      type: Object,
      default() {
        return {};
      },
    },
  },
};
</script>

<style scoped>
.info-title {
  font-size: 18px;
  margin: 10px 5px;
}

.info-price {
  margin-bottom: 15px;
}

.n-price {
  font-size: 22px;
  color: #fa6779;
  margin: 0 5px;
}

.o-price {
  color: #a0a0a0;
  font-size: 13px;
  margin-right: 5px;
  text-decoration: line-through;
}
.discount {
  color: #fff;
  background-color: #fa6779;
  font-size: 13px;
  border-radius: 8px;
  padding: 4px;
}

.info-other {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  color: #a0a0a0;
  border-bottom: 1px solid rgba(100, 100, 100, 0.1);
  padding: 5px;
}
.info-service {
  margin-top: 10px;
  line-height: 20px;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  padding: 5px 5px 10px;
  border-bottom: 2px solid rgba(100, 100, 100, 0.1);
}
.info-service img {
  width: 16px;
}
</style>
